package myAsm;

import java.util.Map;

import javax.persistence.*;


import org.objectweb.asm.MethodVisitor;


@Entity
@DiscriminatorValue("INSN_JUMP")
public class MyJumpInsnNode extends MyAbstractInsnNode{

    /**
     * The operand of this instruction. This operand is a label that designates
     * the instruction to which this instruction may jump.
     */
	@Transient
    public MyLabelNode label;

	public MyJumpInsnNode() {
	        super(-1);
	}
	
    /**
     * Constructs a new {@link JumpInsnNode}.
     * 
     * @param opcode the opcode of the type instruction to be constructed. This
     *        opcode must be IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ,
     *        IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ,
     *        IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL.
     * @param label the operand of the instruction to be constructed. This
     *        operand is a label that designates the instruction to which the
     *        jump instruction may jump.
     */
    public MyJumpInsnNode(final int opcode, final MyLabelNode label) {
        super(opcode);
        this.label = label;
    }

    /**
     * Sets the opcode of this instruction.
     * 
     * @param opcode the new instruction opcode. This opcode must be IFEQ, IFNE,
     *        IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT,
     *        IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO, JSR,
     *        IFNULL or IFNONNULL.
     */
    public void setOpcode(final int opcode) {
        this.opcode = opcode;
    }

    public int getType() {
        return JUMP_INSN;
    }

    public void accept(final MethodVisitor mv) {
        mv.visitJumpInsn(opcode, label.getLabel());
    }

    public MyAbstractInsnNode clone(final Map labels) {
        return new MyJumpInsnNode(opcode, clone(label, labels));
    }
}
